<?php


/**
 * Base class that represents a query for the 'dealers' table.
 *
 *
 *
 * @method DamagesDealersQuery orderById($order = Criteria::ASC) Order by the id column
 * @method DamagesDealersQuery orderByParentId($order = Criteria::ASC) Order by the parent_id column
 * @method DamagesDealersQuery orderByDictBrandId($order = Criteria::ASC) Order by the dict_brand_id column
 * @method DamagesDealersQuery orderByNumber($order = Criteria::ASC) Order by the number column
 * @method DamagesDealersQuery orderByName($order = Criteria::ASC) Order by the name column
 * @method DamagesDealersQuery orderByCity($order = Criteria::ASC) Order by the city column
 * @method DamagesDealersQuery orderByPostCode($order = Criteria::ASC) Order by the post_code column
 * @method DamagesDealersQuery orderByStreet($order = Criteria::ASC) Order by the street column
 * @method DamagesDealersQuery orderByPhoneNo($order = Criteria::ASC) Order by the phone_no column
 * @method DamagesDealersQuery orderByEmail($order = Criteria::ASC) Order by the email column
 * @method DamagesDealersQuery orderByCreated($order = Criteria::ASC) Order by the created column
 * @method DamagesDealersQuery orderByModified($order = Criteria::ASC) Order by the modified column
 *
 * @method DamagesDealersQuery groupById() Group by the id column
 * @method DamagesDealersQuery groupByParentId() Group by the parent_id column
 * @method DamagesDealersQuery groupByDictBrandId() Group by the dict_brand_id column
 * @method DamagesDealersQuery groupByNumber() Group by the number column
 * @method DamagesDealersQuery groupByName() Group by the name column
 * @method DamagesDealersQuery groupByCity() Group by the city column
 * @method DamagesDealersQuery groupByPostCode() Group by the post_code column
 * @method DamagesDealersQuery groupByStreet() Group by the street column
 * @method DamagesDealersQuery groupByPhoneNo() Group by the phone_no column
 * @method DamagesDealersQuery groupByEmail() Group by the email column
 * @method DamagesDealersQuery groupByCreated() Group by the created column
 * @method DamagesDealersQuery groupByModified() Group by the modified column
 *
 * @method DamagesDealersQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method DamagesDealersQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method DamagesDealersQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method DamagesDealersQuery leftJoinDealersRelatedByParentId($relationAlias = null) Adds a LEFT JOIN clause to the query using the DealersRelatedByParentId relation
 * @method DamagesDealersQuery rightJoinDealersRelatedByParentId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the DealersRelatedByParentId relation
 * @method DamagesDealersQuery innerJoinDealersRelatedByParentId($relationAlias = null) Adds a INNER JOIN clause to the query using the DealersRelatedByParentId relation
 *
 * @method DamagesDealersQuery leftJoinDictBrands($relationAlias = null) Adds a LEFT JOIN clause to the query using the DictBrands relation
 * @method DamagesDealersQuery rightJoinDictBrands($relationAlias = null) Adds a RIGHT JOIN clause to the query using the DictBrands relation
 * @method DamagesDealersQuery innerJoinDictBrands($relationAlias = null) Adds a INNER JOIN clause to the query using the DictBrands relation
 *
 * @method DamagesDealersQuery leftJoinCarDataRelatedByDealerId($relationAlias = null) Adds a LEFT JOIN clause to the query using the CarDataRelatedByDealerId relation
 * @method DamagesDealersQuery rightJoinCarDataRelatedByDealerId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CarDataRelatedByDealerId relation
 * @method DamagesDealersQuery innerJoinCarDataRelatedByDealerId($relationAlias = null) Adds a INNER JOIN clause to the query using the CarDataRelatedByDealerId relation
 *
 * @method DamagesDealersQuery leftJoinCarDataRelatedByDealerParentId($relationAlias = null) Adds a LEFT JOIN clause to the query using the CarDataRelatedByDealerParentId relation
 * @method DamagesDealersQuery rightJoinCarDataRelatedByDealerParentId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CarDataRelatedByDealerParentId relation
 * @method DamagesDealersQuery innerJoinCarDataRelatedByDealerParentId($relationAlias = null) Adds a INNER JOIN clause to the query using the CarDataRelatedByDealerParentId relation
 *
 * @method DamagesDealersQuery leftJoinDealersRelatedById($relationAlias = null) Adds a LEFT JOIN clause to the query using the DealersRelatedById relation
 * @method DamagesDealersQuery rightJoinDealersRelatedById($relationAlias = null) Adds a RIGHT JOIN clause to the query using the DealersRelatedById relation
 * @method DamagesDealersQuery innerJoinDealersRelatedById($relationAlias = null) Adds a INNER JOIN clause to the query using the DealersRelatedById relation
 *
 * @method DamagesDealersQuery leftJoinUserDealers($relationAlias = null) Adds a LEFT JOIN clause to the query using the UserDealers relation
 * @method DamagesDealersQuery rightJoinUserDealers($relationAlias = null) Adds a RIGHT JOIN clause to the query using the UserDealers relation
 * @method DamagesDealersQuery innerJoinUserDealers($relationAlias = null) Adds a INNER JOIN clause to the query using the UserDealers relation
 *
 * @method DamagesDealers findOne(PropelPDO $con = null) Return the first DamagesDealers matching the query
 * @method DamagesDealers findOneOrCreate(PropelPDO $con = null) Return the first DamagesDealers matching the query, or a new DamagesDealers object populated from the query conditions when no match is found
 *
 * @method DamagesDealers findOneById(int $id) Return the first DamagesDealers filtered by the id column
 * @method DamagesDealers findOneByParentId(int $parent_id) Return the first DamagesDealers filtered by the parent_id column
 * @method DamagesDealers findOneByDictBrandId(int $dict_brand_id) Return the first DamagesDealers filtered by the dict_brand_id column
 * @method DamagesDealers findOneByNumber(int $number) Return the first DamagesDealers filtered by the number column
 * @method DamagesDealers findOneByName(string $name) Return the first DamagesDealers filtered by the name column
 * @method DamagesDealers findOneByCity(string $city) Return the first DamagesDealers filtered by the city column
 * @method DamagesDealers findOneByPostCode(string $post_code) Return the first DamagesDealers filtered by the post_code column
 * @method DamagesDealers findOneByStreet(string $street) Return the first DamagesDealers filtered by the street column
 * @method DamagesDealers findOneByPhoneNo(string $phone_no) Return the first DamagesDealers filtered by the phone_no column
 * @method DamagesDealers findOneByEmail(string $email) Return the first DamagesDealers filtered by the email column
 * @method DamagesDealers findOneByCreated(string $created) Return the first DamagesDealers filtered by the created column
 * @method DamagesDealers findOneByModified(string $modified) Return the first DamagesDealers filtered by the modified column
 *
 * @method array findById(int $id) Return DamagesDealers objects filtered by the id column
 * @method array findByParentId(int $parent_id) Return DamagesDealers objects filtered by the parent_id column
 * @method array findByDictBrandId(int $dict_brand_id) Return DamagesDealers objects filtered by the dict_brand_id column
 * @method array findByNumber(int $number) Return DamagesDealers objects filtered by the number column
 * @method array findByName(string $name) Return DamagesDealers objects filtered by the name column
 * @method array findByCity(string $city) Return DamagesDealers objects filtered by the city column
 * @method array findByPostCode(string $post_code) Return DamagesDealers objects filtered by the post_code column
 * @method array findByStreet(string $street) Return DamagesDealers objects filtered by the street column
 * @method array findByPhoneNo(string $phone_no) Return DamagesDealers objects filtered by the phone_no column
 * @method array findByEmail(string $email) Return DamagesDealers objects filtered by the email column
 * @method array findByCreated(string $created) Return DamagesDealers objects filtered by the created column
 * @method array findByModified(string $modified) Return DamagesDealers objects filtered by the modified column
 *
 * @package    propel.generator.damages.om
 */
abstract class DamagesBaseDealersQuery extends ModelCriteria
{
    /**
     * Initializes internal state of DamagesBaseDealersQuery object.
     *
     * @param     string $dbName The dabase name
     * @param     string $modelName The phpName of a model, e.g. 'Book'
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     */
    public function __construct($dbName = 'vgp_damages', $modelName = 'DamagesDealers', $modelAlias = null)
    {
        parent::__construct($dbName, $modelName, $modelAlias);
    }

    /**
     * Returns a new DamagesDealersQuery object.
     *
     * @param     string $modelAlias The alias of a model in the query
     * @param     DamagesDealersQuery|Criteria $criteria Optional Criteria to build the query from
     *
     * @return DamagesDealersQuery
     */
    public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof DamagesDealersQuery) {
            return $criteria;
        }
        $query = new DamagesDealersQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }

    /**
     * Find object by primary key.
     * Propel uses the instance pool to skip the database if the object exists.
     * Go fast if the query is untouched.
     *
     * <code>
     * $obj  = $c->findPk(12, $con);
     * </code>
     *
     * @param mixed $key Primary key to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return   DamagesDealers|DamagesDealers[]|mixed the result, formatted by the current formatter
     */
    public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = DamagesDealersPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
            // the object is alredy in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getConnection(DamagesDealersPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

    /**
     * Find object by primary key using raw SQL to go fast.
     * Bypass doSelect() and the object formatter by using generated code.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return   DamagesDealers A model object, or null if the key is not found
     * @throws   PropelException
     */
    protected function findPkSimple($key, $con)
    {
        $sql = 'SELECT ID, PARENT_ID, DICT_BRAND_ID, NUMBER, NAME, CITY, POST_CODE, STREET, PHONE_NO, EMAIL, CREATED, MODIFIED FROM dealers WHERE ID = :p0';
        try {
            $stmt = $con->prepare($sql);
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
        }
        $obj = null;
        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $obj = new DamagesDealers();
            $obj->hydrate($row);
            DamagesDealersPeer::addInstanceToPool($obj, (string) $key);
        }
        $stmt->closeCursor();

        return $obj;
    }

    /**
     * Find object by primary key.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return DamagesDealers|DamagesDealers[]|mixed the result, formatted by the current formatter
     */
    protected function findPkComplex($key, $con)
    {
        // As the query uses a PK condition, no limit(1) is necessary.
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKey($key)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    }

    /**
     * Find objects by primary key
     * <code>
     * $objs = $c->findPks(array(12, 56, 832), $con);
     * </code>
     * @param     array $keys Primary keys to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return PropelObjectCollection|DamagesDealers[]|mixed the list of results, formatted by the current formatter
     */
    public function findPks($keys, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKeys($keys)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->format($stmt);
    }

    /**
     * Filter the query by primary key
     *
     * @param     mixed $key Primary key to use for the query
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function filterByPrimaryKey($key)
    {

        return $this->addUsingAlias(DamagesDealersPeer::ID, $key, Criteria::EQUAL);
    }

    /**
     * Filter the query by a list of primary keys
     *
     * @param     array $keys The list of primary key to use for the query
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function filterByPrimaryKeys($keys)
    {

        return $this->addUsingAlias(DamagesDealersPeer::ID, $keys, Criteria::IN);
    }

    /**
     * Filter the query on the id column
     *
     * Example usage:
     * <code>
     * $query->filterById(1234); // WHERE id = 1234
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
     * $query->filterById(array('min' => 12)); // WHERE id > 12
     * </code>
     *
     * @param     mixed $id The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function filterById($id = null, $comparison = null)
    {
        if (is_array($id) && null === $comparison) {
            $comparison = Criteria::IN;
        }

        return $this->addUsingAlias(DamagesDealersPeer::ID, $id, $comparison);
    }

    /**
     * Filter the query on the parent_id column
     *
     * Example usage:
     * <code>
     * $query->filterByParentId(1234); // WHERE parent_id = 1234
     * $query->filterByParentId(array(12, 34)); // WHERE parent_id IN (12, 34)
     * $query->filterByParentId(array('min' => 12)); // WHERE parent_id > 12
     * </code>
     *
     * @see       filterByDealersRelatedByParentId()
     *
     * @param     mixed $parentId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function filterByParentId($parentId = null, $comparison = null)
    {
        if (is_array($parentId)) {
            $useMinMax = false;
            if (isset($parentId['min'])) {
                $this->addUsingAlias(DamagesDealersPeer::PARENT_ID, $parentId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($parentId['max'])) {
                $this->addUsingAlias(DamagesDealersPeer::PARENT_ID, $parentId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesDealersPeer::PARENT_ID, $parentId, $comparison);
    }

    /**
     * Filter the query on the dict_brand_id column
     *
     * Example usage:
     * <code>
     * $query->filterByDictBrandId(1234); // WHERE dict_brand_id = 1234
     * $query->filterByDictBrandId(array(12, 34)); // WHERE dict_brand_id IN (12, 34)
     * $query->filterByDictBrandId(array('min' => 12)); // WHERE dict_brand_id > 12
     * </code>
     *
     * @see       filterByDictBrands()
     *
     * @param     mixed $dictBrandId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function filterByDictBrandId($dictBrandId = null, $comparison = null)
    {
        if (is_array($dictBrandId)) {
            $useMinMax = false;
            if (isset($dictBrandId['min'])) {
                $this->addUsingAlias(DamagesDealersPeer::DICT_BRAND_ID, $dictBrandId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($dictBrandId['max'])) {
                $this->addUsingAlias(DamagesDealersPeer::DICT_BRAND_ID, $dictBrandId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesDealersPeer::DICT_BRAND_ID, $dictBrandId, $comparison);
    }

    /**
     * Filter the query on the number column
     *
     * Example usage:
     * <code>
     * $query->filterByNumber(1234); // WHERE number = 1234
     * $query->filterByNumber(array(12, 34)); // WHERE number IN (12, 34)
     * $query->filterByNumber(array('min' => 12)); // WHERE number > 12
     * </code>
     *
     * @param     mixed $number The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function filterByNumber($number = null, $comparison = null)
    {
        if (is_array($number)) {
            $useMinMax = false;
            if (isset($number['min'])) {
                $this->addUsingAlias(DamagesDealersPeer::NUMBER, $number['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($number['max'])) {
                $this->addUsingAlias(DamagesDealersPeer::NUMBER, $number['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesDealersPeer::NUMBER, $number, $comparison);
    }

    /**
     * Filter the query on the name column
     *
     * Example usage:
     * <code>
     * $query->filterByName('fooValue');   // WHERE name = 'fooValue'
     * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
     * </code>
     *
     * @param     string $name The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function filterByName($name = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($name)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $name)) {
                $name = str_replace('*', '%', $name);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(DamagesDealersPeer::NAME, $name, $comparison);
    }

    /**
     * Filter the query on the city column
     *
     * Example usage:
     * <code>
     * $query->filterByCity('fooValue');   // WHERE city = 'fooValue'
     * $query->filterByCity('%fooValue%'); // WHERE city LIKE '%fooValue%'
     * </code>
     *
     * @param     string $city The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function filterByCity($city = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($city)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $city)) {
                $city = str_replace('*', '%', $city);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(DamagesDealersPeer::CITY, $city, $comparison);
    }

    /**
     * Filter the query on the post_code column
     *
     * Example usage:
     * <code>
     * $query->filterByPostCode('fooValue');   // WHERE post_code = 'fooValue'
     * $query->filterByPostCode('%fooValue%'); // WHERE post_code LIKE '%fooValue%'
     * </code>
     *
     * @param     string $postCode The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function filterByPostCode($postCode = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($postCode)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $postCode)) {
                $postCode = str_replace('*', '%', $postCode);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(DamagesDealersPeer::POST_CODE, $postCode, $comparison);
    }

    /**
     * Filter the query on the street column
     *
     * Example usage:
     * <code>
     * $query->filterByStreet('fooValue');   // WHERE street = 'fooValue'
     * $query->filterByStreet('%fooValue%'); // WHERE street LIKE '%fooValue%'
     * </code>
     *
     * @param     string $street The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function filterByStreet($street = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($street)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $street)) {
                $street = str_replace('*', '%', $street);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(DamagesDealersPeer::STREET, $street, $comparison);
    }

    /**
     * Filter the query on the phone_no column
     *
     * Example usage:
     * <code>
     * $query->filterByPhoneNo('fooValue');   // WHERE phone_no = 'fooValue'
     * $query->filterByPhoneNo('%fooValue%'); // WHERE phone_no LIKE '%fooValue%'
     * </code>
     *
     * @param     string $phoneNo The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function filterByPhoneNo($phoneNo = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($phoneNo)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $phoneNo)) {
                $phoneNo = str_replace('*', '%', $phoneNo);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(DamagesDealersPeer::PHONE_NO, $phoneNo, $comparison);
    }

    /**
     * Filter the query on the email column
     *
     * Example usage:
     * <code>
     * $query->filterByEmail('fooValue');   // WHERE email = 'fooValue'
     * $query->filterByEmail('%fooValue%'); // WHERE email LIKE '%fooValue%'
     * </code>
     *
     * @param     string $email The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function filterByEmail($email = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($email)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $email)) {
                $email = str_replace('*', '%', $email);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(DamagesDealersPeer::EMAIL, $email, $comparison);
    }

    /**
     * Filter the query on the created column
     *
     * Example usage:
     * <code>
     * $query->filterByCreated('2011-03-14'); // WHERE created = '2011-03-14'
     * $query->filterByCreated('now'); // WHERE created = '2011-03-14'
     * $query->filterByCreated(array('max' => 'yesterday')); // WHERE created > '2011-03-13'
     * </code>
     *
     * @param     mixed $created The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function filterByCreated($created = null, $comparison = null)
    {
        if (is_array($created)) {
            $useMinMax = false;
            if (isset($created['min'])) {
                $this->addUsingAlias(DamagesDealersPeer::CREATED, $created['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($created['max'])) {
                $this->addUsingAlias(DamagesDealersPeer::CREATED, $created['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesDealersPeer::CREATED, $created, $comparison);
    }

    /**
     * Filter the query on the modified column
     *
     * Example usage:
     * <code>
     * $query->filterByModified('2011-03-14'); // WHERE modified = '2011-03-14'
     * $query->filterByModified('now'); // WHERE modified = '2011-03-14'
     * $query->filterByModified(array('max' => 'yesterday')); // WHERE modified > '2011-03-13'
     * </code>
     *
     * @param     mixed $modified The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function filterByModified($modified = null, $comparison = null)
    {
        if (is_array($modified)) {
            $useMinMax = false;
            if (isset($modified['min'])) {
                $this->addUsingAlias(DamagesDealersPeer::MODIFIED, $modified['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($modified['max'])) {
                $this->addUsingAlias(DamagesDealersPeer::MODIFIED, $modified['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesDealersPeer::MODIFIED, $modified, $comparison);
    }

    /**
     * Filter the query by a related DamagesDealers object
     *
     * @param   DamagesDealers|PropelObjectCollection $dealers The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesDealersQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByDealersRelatedByParentId($dealers, $comparison = null)
    {
        if ($dealers instanceof DamagesDealers) {
            return $this
                ->addUsingAlias(DamagesDealersPeer::PARENT_ID, $dealers->getId(), $comparison);
        } elseif ($dealers instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(DamagesDealersPeer::PARENT_ID, $dealers->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByDealersRelatedByParentId() only accepts arguments of type DamagesDealers or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the DealersRelatedByParentId relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function joinDealersRelatedByParentId($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('DealersRelatedByParentId');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'DealersRelatedByParentId');
        }

        return $this;
    }

    /**
     * Use the DealersRelatedByParentId relation Dealers object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesDealersQuery A secondary query class using the current class as primary query
     */
    public function useDealersRelatedByParentIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        return $this
            ->joinDealersRelatedByParentId($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'DealersRelatedByParentId', 'DamagesDealersQuery');
    }

    /**
     * Filter the query by a related DamagesDictBrands object
     *
     * @param   DamagesDictBrands|PropelObjectCollection $dictBrands The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesDealersQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByDictBrands($dictBrands, $comparison = null)
    {
        if ($dictBrands instanceof DamagesDictBrands) {
            return $this
                ->addUsingAlias(DamagesDealersPeer::DICT_BRAND_ID, $dictBrands->getId(), $comparison);
        } elseif ($dictBrands instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(DamagesDealersPeer::DICT_BRAND_ID, $dictBrands->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByDictBrands() only accepts arguments of type DamagesDictBrands or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the DictBrands relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function joinDictBrands($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('DictBrands');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'DictBrands');
        }

        return $this;
    }

    /**
     * Use the DictBrands relation DictBrands object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesDictBrandsQuery A secondary query class using the current class as primary query
     */
    public function useDictBrandsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinDictBrands($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'DictBrands', 'DamagesDictBrandsQuery');
    }

    /**
     * Filter the query by a related DamagesCarData object
     *
     * @param   DamagesCarData|PropelObjectCollection $carData  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesDealersQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByCarDataRelatedByDealerId($carData, $comparison = null)
    {
        if ($carData instanceof DamagesCarData) {
            return $this
                ->addUsingAlias(DamagesDealersPeer::ID, $carData->getDealerId(), $comparison);
        } elseif ($carData instanceof PropelObjectCollection) {
            return $this
                ->useCarDataRelatedByDealerIdQuery()
                ->filterByPrimaryKeys($carData->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByCarDataRelatedByDealerId() only accepts arguments of type DamagesCarData or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the CarDataRelatedByDealerId relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function joinCarDataRelatedByDealerId($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('CarDataRelatedByDealerId');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'CarDataRelatedByDealerId');
        }

        return $this;
    }

    /**
     * Use the CarDataRelatedByDealerId relation CarData object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesCarDataQuery A secondary query class using the current class as primary query
     */
    public function useCarDataRelatedByDealerIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        return $this
            ->joinCarDataRelatedByDealerId($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'CarDataRelatedByDealerId', 'DamagesCarDataQuery');
    }

    /**
     * Filter the query by a related DamagesCarData object
     *
     * @param   DamagesCarData|PropelObjectCollection $carData  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesDealersQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByCarDataRelatedByDealerParentId($carData, $comparison = null)
    {
        if ($carData instanceof DamagesCarData) {
            return $this
                ->addUsingAlias(DamagesDealersPeer::ID, $carData->getDealerParentId(), $comparison);
        } elseif ($carData instanceof PropelObjectCollection) {
            return $this
                ->useCarDataRelatedByDealerParentIdQuery()
                ->filterByPrimaryKeys($carData->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByCarDataRelatedByDealerParentId() only accepts arguments of type DamagesCarData or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the CarDataRelatedByDealerParentId relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function joinCarDataRelatedByDealerParentId($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('CarDataRelatedByDealerParentId');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'CarDataRelatedByDealerParentId');
        }

        return $this;
    }

    /**
     * Use the CarDataRelatedByDealerParentId relation CarData object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesCarDataQuery A secondary query class using the current class as primary query
     */
    public function useCarDataRelatedByDealerParentIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        return $this
            ->joinCarDataRelatedByDealerParentId($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'CarDataRelatedByDealerParentId', 'DamagesCarDataQuery');
    }

    /**
     * Filter the query by a related DamagesDealers object
     *
     * @param   DamagesDealers|PropelObjectCollection $dealers  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesDealersQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByDealersRelatedById($dealers, $comparison = null)
    {
        if ($dealers instanceof DamagesDealers) {
            return $this
                ->addUsingAlias(DamagesDealersPeer::ID, $dealers->getParentId(), $comparison);
        } elseif ($dealers instanceof PropelObjectCollection) {
            return $this
                ->useDealersRelatedByIdQuery()
                ->filterByPrimaryKeys($dealers->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByDealersRelatedById() only accepts arguments of type DamagesDealers or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the DealersRelatedById relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function joinDealersRelatedById($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('DealersRelatedById');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'DealersRelatedById');
        }

        return $this;
    }

    /**
     * Use the DealersRelatedById relation Dealers object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesDealersQuery A secondary query class using the current class as primary query
     */
    public function useDealersRelatedByIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        return $this
            ->joinDealersRelatedById($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'DealersRelatedById', 'DamagesDealersQuery');
    }

    /**
     * Filter the query by a related DamagesUserDealers object
     *
     * @param   DamagesUserDealers|PropelObjectCollection $userDealers  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesDealersQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByUserDealers($userDealers, $comparison = null)
    {
        if ($userDealers instanceof DamagesUserDealers) {
            return $this
                ->addUsingAlias(DamagesDealersPeer::ID, $userDealers->getDealerId(), $comparison);
        } elseif ($userDealers instanceof PropelObjectCollection) {
            return $this
                ->useUserDealersQuery()
                ->filterByPrimaryKeys($userDealers->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByUserDealers() only accepts arguments of type DamagesUserDealers or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the UserDealers relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function joinUserDealers($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('UserDealers');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'UserDealers');
        }

        return $this;
    }

    /**
     * Use the UserDealers relation UserDealers object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesUserDealersQuery A secondary query class using the current class as primary query
     */
    public function useUserDealersQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinUserDealers($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'UserDealers', 'DamagesUserDealersQuery');
    }

    /**
     * Exclude object from result
     *
     * @param   DamagesDealers $dealers Object to remove from the list of results
     *
     * @return DamagesDealersQuery The current query, for fluid interface
     */
    public function prune($dealers = null)
    {
        if ($dealers) {
            $this->addUsingAlias(DamagesDealersPeer::ID, $dealers->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }

}
